/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DickYang
 * Date: 2023-05-06
 * Time: 16:33
 */

//继承 关键字extends
class Animal {
    public String name;
    public int age;
    public int a = 99;

    public Animal() {

    }
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println(name +" 正在吃饭！");
    }
}

class Dog extends Animal {
    public int a = 9;
    public void func1() {
        //当子类与父类有相同成员变量或成员方法时，优先调用子类的，调用父类的需要通过关键字super访问！！！
        System.out.println(a);
        System.out.println(super.a);
    }
    //子类在进行构造的时候必须先给父类构造!!
    public Dog() {
        super("十一月",12);//当在子类调用无参构造方法时，Java会默认帮你加上super(),然后调用父类的无参构造方法!
    }
    public Dog(String name, int age) {
        super(name, age);
    }

    public void wangwang() {
        System.out.println(name + " 正在汪汪叫！");
    }
}

public class TestDome1 {
    public static void main(String[] args) {
        Dog dog = new Dog();
        System.out.println(dog.name);
        System.out.println(dog.age);
        dog.func1();
    }
    public static void main1(String[] args) {
        Dog dog = new Dog("坦克",4);
        dog.eat();
        dog.wangwang();
    }
}
